package com.pcitc.app.service.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.pcitc.app.dao.TblUserDao;
import com.pcitc.app.dao.TblOrgDao;
import com.pcitc.app.model.TblUser;
import com.pcitc.app.model.TblOrg;
import com.pcitc.app.service.TblUserManager;

public class TblUserManagerImpl extends UniversalManagerImpl implements TblUserManager {

	private TblUserDao tblUserDao;
	private TblOrgDao tblOrgDao;
	
	public void setTblUserDao(TblUserDao tblUserDao) {
		this.tblUserDao = tblUserDao;
	}
	public void setTblOrgDao(TblOrgDao tblOrgDao) {
		this.tblOrgDao = tblOrgDao;
	}
	/**
	 * @author zhangbin
	 * 根据用户名查找用户
	 * @param username
	 * @return
	 */
    @Transactional
    public TblUser loadUserByUsername(String username){
    	return this.tblUserDao.loadUserByUsername(username);
    }
    
    /**
     * @author zhangbin
     * 根据用户ID查找用户
     * @param userid
     * @return
     */
    public TblUser loadUserByUserId(Long userid){
    	return this.tblUserDao.loadUserByUserId(userid);
    }
    
    /**
     * @author zhangbin
     * 根据USER超找用户
     * @param tblUser
     * @return
     */
    public List<TblUser> findByExample(TblUser tblUser){
    	return this.tblUserDao.findByExample(tblUser);
    }
    /**
     * @author zhangbin
     * 根据USER超找用户
     * @param tblUser
     * @return
     */
    public List<TblOrg> getOrgList(){
    	return this.tblOrgDao.getOrgList();
    }
    /**
     * @author zhangbin
     * 获取用户列表
     * @return
     */
    public List<TblUser> getUserList(){
    	return this.tblUserDao.getUserList();
    }
    
    /**
     * @author zhangbin
     * 保存用户
     * @param tblUser
     * @return
     */
    public void saveUser(TblUser tblUser){
    	this.tblUserDao.saveUser(tblUser);
    }
    
    /**
     * @author zhangbin
     * 更新用户
     * @param tblUser
     * @return
     */
    public TblUser upateUser(TblUser tblUser){
    	return this.tblUserDao.upateUser(tblUser);
    }
    
    /**
     * @author zhangbin
     * 删除用户
     * @param tblUser
     */
    public void removeUser(TblUser tblUser){
    	this.tblUserDao.removeUser(tblUser);
    }
    
    /**
     * @author zhangbin
     * 根据用户ID删除用户
     * @param userid
     */
    public void removeUserByID(Long userid){
    	this.tblUserDao.removeUserByID(userid);
    }    
    /**
     * @author zhangbin
     *  删除所有
     * @param tblUsers
     */
    public void removeAll(List<TblUser> tblUsers){
    	this.tblUserDao.removeAll(tblUsers);
    }
    
    /**
     * @author zhangbin
     * 检查用户名密码 返回USER
     * @param userName
     * @param pwd
     * @return
     */ 
    public TblUser checkUserPassword(String userName, String pwd){
    	return this.tblUserDao.checkUserPassword(userName, pwd);
    }
    
    
    /**
     * @author zhangbin
     * 检查用户名密码 返回Boolea值ֵ
     * @param userName
     * @param pwd
     * @return
     */
    public boolean isValidUser(String userName, String pwd){
    	return this.tblUserDao.isValidUser(userName, pwd);
    }
    
    /**
     * @author zhangbin
     * 检查用户ID是否存在 返回Booleanֵ值
     * @param userid
     * @return
     */
    public boolean checkUserId(Long userid){
    	return this.tblUserDao.checkUserId(userid);
    }
    
    /**
     * @author zhangbin
     * 修改用户密码
     * @param userId
     * @param oldPwd
     * @param newPwd
     * @return
     */
    public boolean changePwd(Long userId,String oldPwd, String newPwd){
    	return this.tblUserDao.changePwd(userId, oldPwd, newPwd);
    }
    
    /**
     * @author zhangbin
     * 获取用户密码
     * @param username
     * @return
     */
    @Transactional(propagation = Propagation.NOT_SUPPORTED)
    public String getUserPassword(String username){
    	return this.tblUserDao.getUserPassword(username);
    }


}
